package cn.bdqn.controller;

import cn.bdqn.entity.Country;
import cn.bdqn.entity.Result;
import cn.bdqn.service.CountryService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("country")
public class CountryController  {
    @Resource
    private CountryService countryService;


    @GetMapping
    public Result<List<Country>> queryAll() {
        return Result.ok(this.countryService.queryAll());
    }

    @GetMapping("{id}")
    public ResponseEntity<Country> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.countryService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<Country> add(Country country) {
        return ResponseEntity.ok(this.countryService.insert(country));
    }

    @PutMapping
    public ResponseEntity<Country> edit(Country country) {
        return ResponseEntity.ok(this.countryService.update(country));
    }
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.countryService.deleteById(id));
    }

}

